<template>
    <div>
        <div class="cardsviews">
            <div class="cardimgs">
                <!--<img v-show="imgsUrl.gsurl" :src="imgsUrl.gsurl"/>-->
                <img v-show="!imgsUrl.gsurl" src="../../assets/img/gscard.png"/>
                <img v-show="imgsUrl.gsurl" :src="imgsUrl.gsurl"/>
                <wxupload ref="gsupload" v-if="binfo.sign_status!=1" choosetype="3" @uploadsucess="uploadsucess"></wxupload>
              <div v-show="!imgsUrl.gsurl" style="margin-top: -30px;padding-bottom: 20px;" class="tipinfo">请上传工商截图</div>
            </div>


        </div>

      <div style="text-align: center">
        <div style="background-color: #3E8CF3; margin:0 auto; line-height:40px; color:#FFF;border-radius:5px; width: 90%; height: 40px; "   :style="{background:$store.state.themcolor}" @click="okgs">确定</div>
      </div>

      <div v-show="!imgsUrl.gsurl" class="cardsviews" style="margin-top: 20px; padding: 10px 20px;">
        <div class="tipinfo">上传工商截图示例</div>
        <div class="cardimgs">
          <img src="../../assets/img/case.png"/>
        </div>


      </div>

    </div>

</template>

<script>
    import {HOST, IMG_URL} from '@/constants'
    export default {
        name: "mobile-card",
        props: ['binfo'],
        data() {
            return {
                imgsUrl: {
                    gsurl: '',
                },
            }
        },
        created() {
            //获取默认图片
            if(this.binfo.industry_pic) {
                this.imgsUrl.gsurl = IMG_URL + this.binfo.industry_pic
            }

        },
        methods: {
          okgs(){
            if(!this.imgsUrl.gsurl){
              this.$message({
                message: '请上传工商截图',
                type: 'error',
                showClose: true
              });
              return false
            }else{
              this.close()
            }
          },
            uploadsucess(value) {
                // alert(JSON.stringify(value))
                if (value.type == 3) {
                    let self = this;
                    this.request.post('employees/saveGsImg', {
                        gsUrl: value.key,
                        checkUrl: IMG_URL+value.key,
                        out_members_id: this.binfo.out_members_id,
                        cmloading: true
                    }).then((res)=>{
                        if(res.code == 0) {
                            self.imgsUrl.gsurl = value.img
                            self.callback(value.key);
                        } else {
                            alert(res.msg)
                          this.$refs.gsupload.$refs.inputer.value=''
                        }

                    })

                }
            }

        }
    }
</script>

<style lang="scss" scoped>
    .cardsviews {
        margin: 0 30px;
        padding: 20px 0;
        position: relative;

    .cardimgs {
        position: relative;
        overflow: hidden;

    img {
        width: 100%;
    }

    }
    .tipinfo {
        text-align: center;
        color: #040404;
    }

    }
</style>
